package tech.jabari.utils;

import java.util.Map;

/**
 * @author Jabari Lu
 * @title: JsonUtil
 * @data 2020/8/4 9:27
 */
public class JsonUtil {

    /**
     *
     * @param data
     * @param key
     * @param isLast - boolean - 是否是最后一个
     * @param isStringType - boolean - 是否是字符串类型
     * @return
     */
    public static String getStr(Map<String,Object> data, String key,
                                boolean isLast,boolean isStringType) {
        String ret = "";
        /*String ret = "\""+ key + "\":\""+data.get(key)+"\"";*/
        if (isStringType) {
            ret = "\""+ key + "\":\""+data.get(key)+"\"";
        } else {
            ret = "\""+ key + "\":"+data.get(key)+"";
        }
        if (!isLast) {
            ret += ",";
        }
        return ret;
    }


}
